package com.etc.delivery.controller.admin;

import com.etc.delivery.entity.User;
import com.etc.delivery.service.admin.IAdminUserService;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RequestMapping(value = "/admin")
@Controller
public class AdminUserController {

    @Resource
    private IAdminUserService userService;


    @RequestMapping(value = "/queryUser")
    @ResponseBody
    public PageInfo<User> queryUser(String name, Integer pageNum, Integer pageSize) {


        return userService.queryUser(name, pageNum, pageSize);
    }

    @RequestMapping(value = "deleteUser")
    @ResponseBody
    public Map<String, String> deleteUser(Integer id) {
        Map<String, String> map = new HashMap<>();
        boolean flag = userService.deleteUser(id);
        if (flag) {
            map.put("code", "1");
            map.put("msg", "删除成功");
        } else {
            map.put("code", "0");
            map.put("msg", "删除失败");
        }
        return map;
    }


}
